function save(payload) {
    console.log("---START-product-save---", payload)

    let user_id = Process("session.Get", "user_id");
    payload.oper_id = user_id
    let res = Process("models.product.Save", payload);
    return { "id": res };
    //  payload.user_id = user_id;
    //  console.log("payload-user_id:", payload.user_id);


}


/**
* 在关联处理器 find 之前运行
* @param id 数据记录主键数值
* @param query 查询参数
*/
function beforeFind(id, query, ...args) {
    console.log("---BeforeFind-START--")
    console.log(id, query)
    console.log("args", args)
    console.log("---BeforeFind-END--")
    return [id, query];
}

function afterSearch(data) {
    // data = Process("scripts.utils.AfterSearchForTimeProcess", data);
    //  let motor_lifespan = [{
    //     "motor_type": "gripper_motor",
    //   },
    //  {
    //      "motor_type": "wrist_flex_ext_motor",
    //  },
    //   {
    //     "motor_type": "wrist_rotation_motor"
    //   }];
    //  data.motor_lifespan = motor_lifespan;
    console.log("------", data);
    return data;
}

function onChange(query) {
    console.log("query-->", query)
    // 进入onchange事件
    query = query || {};
    field = query.key;
    newVal = query.value;
    oldVal = query.old;

    let data = { query: query };
    console.log("data-->", data)
    if (newVal == "cat") {
        data.cost = 1000;
    } else {
        data.cost = 2000;
    }
    console.log("data-1->", data)
    let setting = Process("yao.form.Setting", "product");

    if (setting && setting.code && setting.message) {
        throw new Exception(setting.message, 500);
    }

    return {
        data: data,
        setting: setting,
    };
}